Repository navigation
SV study: --full-output writes V0s with the raw clusters of their prongs - #16277
Open
matthias-kleiner wants to merge 2 commits into
Open
matthias-kleiner wants to merge 2 commits into
matthias-kleiner wants to merge 2 commits into
Conversation
o2-sv-study-workflow --full-output selects K0s, Lambda, anti-Lambda and photon conversions among the V0 finder's V0s and writes them, with everything needed to refit their prongs offline, to o2_v0s_full.root (one entry per TF). New data format DataFormatsGlobalTracking/ TrackV0Extended.h, built like TrackCosmicsExtended.h: - per V0: its two prongs, each with its raw TPC clusters (plus the sharing-map byte), ITS compact clusters and patterns, the matched TOF cluster and the TRD tracklets; the track parameters, times and TOF match of the reconstruction; the assigned primary vertex; selection variables and the downsampling weight - per TF: the TPC transformation info, the TPC occupancy map, the TF ID - with MC input also the MC truth of each prong and of the V0 (common mother of the prongs: PDG code, momentum, production point, its mother), as the kinematics are not kept in MC productions Selection and downsampling (svFullOutput.*, V0FullOutputParams.h): cuts per class, far K0s / Lambda (beyond maxR, both legs without ITS) with their own cuts; flat in log V0 pT per class with a cap per TF and pT bin. Caps >= 1 keep at most int(cap) V0s, caps < 1 keep each V0 with probability cap / candidates (for full passes); the weights restore the spectrum. Random numbers from the TF and the prong tracks. Existing study device: the V0 refit (--refit, or when the finder does not send full V0s) now prepares TPC-only prongs as the V0 finder does (shifted to the vertex time, drift from VDriftHelper), so it reproduces the finder's V0s; svStudy.root changes in refit mode for such V0s. New option --disable-study-tree. calib-workflow.sh: CALIB_ASYNC_EXTRACTV0S=1 runs the extraction in the reconstruction chain (with svertexer.createFullV0s=true the V0s are not refitted). Code review: two rounds by Claude Fable 5.2; all findings addressed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ition With svertexer.createFullV0s, the copy of a V0 that the finder adds for a cascade at another primary vertex got its cosPA from V0::getX()/getY(), i.e. from the coordinates in the V0's sector frame, combined with the global position of the vertex. The cosPA of these copies was wrong (e.g. -0.83 instead of 0.93). Use the global position of the V0 (getXYZGlo). Only the full V0 output (createFullV0s=true) is affected; the V0 indices, the fits and the AOD are unchanged. Test: Pb-Pb MC TF with the cascade finder: 2 of 1782 V0s are such copies; their cosPA changes from -0.83 / -0.23 to 0.93 / 0.99, nothing else changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New option
o2-sv-study-workflow --full-output. It selects K0s, Λ / anti-Λ and photon conversions among the V0 finder's V0s and writes them too2_v0s_full.root(one entry per TF) with everything needed to refit their prongs offline. The new data formatDataFormatsGlobalTracking/TrackV0Extended.hfollowsTrackCosmicsExtended.h: each V0 is self-contained, with its two prongs, each with its raw TPC clusters (plus the reconstruction's sharing-map byte), ITS compact clusters and patterns, the matched TOF cluster and the TRD tracklets; the reconstruction's track parameters, times and TOF match; the assigned primary vertex and the selection variables. Per TF it also stores the TPC transformation info, the TPC occupancy map and the TF ID. With MC input the file also carries the MC truth, since the kinematics are not kept in MC productions: per prong its PDG code, momentum and production point, per V0 the common mother of the prongs if they come from its displaced decay or conversion (label, PDG code, momentum, production point, its own mother and whether it comes from the generator; beam particles, hadronic interactions in material and prompt decays excluded). Without readable MC files the labels are written without truth (one warning); the MC events are released after each TF. On a Pb-Pb MC TF: 93 % of the K0s and 81 % of the photons are true, decay radius true vs reconstructed 0.10 cm for K0s.Selection and downsampling are configurable (
svFullOutput.*,V0FullOutputParams.h). Defaults: K0s / Λ with 5 < r < 35 cm; far K0s / Λ (both legs without ITS, up to 250 cm) with their own cuts; photons with the O2Physics Armenteros ellipse. Downsampling per class flat in V0 pT with a cap per TF and log-pT bin (svFullOutput.maxPerBin*): cap >= 1 keeps at most int(cap) V0s (weight candidates / kept; default 5, i.e. at most 440 V0s per TF besides the rare far ones); cap < 1 keeps each V0 with probability cap / candidates (weight candidates / cap), for a full reconstruction pass (about one V0 per TF and class with caps of 0.05-0.08). The random numbers come from the TF and the prong tracks, so the sample does not depend on the V0 finder's threads.calib-workflow.sh:CALIB_ASYNC_EXTRACTV0S=1runs the extraction in the reconstruction chain (--disable-study-treeskipssvStudy.root). The V0 finder's indices are enough (production default,svertexer.createFullV0s=false): the selected V0s are refitted with the finder's fitter and settings and are the finder's V0s (see below). Withsvertexer.createFullV0s=truethe refit is skipped.Also changed in the existing study device: its V0 refit (
--refit, or when the finder sends no full V0s) now prepares TPC-only prongs as the V0 finder does (shifted in z to the vertex time,VDriftHelper); before, they were fitted at their own time0. On a Pb-Pb MC TF the refit now reproduces the finder's V0s bit-identically (336 / 336). This changessvStudy.rootin refit mode for V0s with TPC-only prongs.Why. V0s with a known mass and a common displaced vertex constrain the alignment and the TPC distortion corrections (common-vertex and mass constraints in the global alignment; re-transforming the clusters with a new TPC map and checking the mass). That needs the raw clusters, which the reconstruction output does not keep. The TPC refit reproduces the reconstruction only if the sharing map and the occupancy map are stored too: without the sharing map the TPC-only V0 mass moves by up to 15 MeV.
Test. Pb-Pb MC (1 TF): the prongs refitted from the stored clusters equal the refit from the original clusters to the bit (653 / 653); the downsampling keeps min(cap, candidates) per class and pT bin, and the weights add up exactly to the selected numbers. Pb-Pb data, run 568041: 3000 TFs extracted in the reconstruction chain via
CALIB_ASYNC_EXTRACTV0S(same code without downsampling): about 1400 V0s and 3.6–3.9 MB per TF (unbinned TPC residuals of the same run: 81.7 MB per TF). With the default downsampling (run 568663, 22 kHz, 10 TFs): 203 V0s and 0.59 MB per TF instead of 1564 V0s and 3.97 MB. With the caps for a full pass (K0s 0.08, Λ 0.05, photons 0.05, far 0.03; 50 CTFs = 2349 TFs): 2.9 V0s and 13 kB per TF (about 1 K0s, 0.5 Λ, 0.5 anti-Λ, 0.9 photons).Effect on production. Nothing changes unless
--full-output/CALIB_ASYNC_EXTRACTV0Sis set; the existing study tree is unchanged except in refit mode (see above). When enabled, the writer only reads and no setting of the reconstruction changes, so the AOD does not change. CPU (Pb-Pb data, 22 kHz, 50 CTFs = 2349 TFs, full-pass caps): the extraction runs as a separate process next to the chain and needs about a quarter of the V0 finder's CPU, the same with the finder's indices only (25.9 %) as with its full V0s (25.3 %).Indices vs full V0s (Pb-Pb data, run 568663, same 50 CTFs = 2349 TFs, full-pass caps): 6880 = 6880 V0s, all the same V0s, 6859 identical in every stored value; the other 21 have identical fits and differ only in
cosPA2and in a weight, both from the wrong cosPA of the finder's cascade copies fixed in the second commit.Second commit (SVertexer). With
svertexer.createFullV0s, the copy of a V0 that the finder adds for a cascade at another primary vertex got its cosPA fromV0::getX()/getY(), i.e. from the coordinates in the V0's sector frame, combined with the global position of the vertex. It now uses the global V0 position. Only the full V0 output is affected; the indices, the fits and the AOD are unchanged. Pb-Pb MC TF with the cascade finder: 2 of 1782 V0s are such copies, their cosPA changes from -0.83 / -0.23 to 0.93 / 0.99, nothing else changes.Review. The code was reviewed by Claude Fable 5.2 in four rounds (two of the whole commit, two of the MC truth); all findings were addressed (among them the refit of TPC-only prongs above, a thread-independent sampling, the ITS staggering flag in the chain, the definition of a true V0 and the handling of missing MC files).
Armenteros-Podolanski plot of the written V0s (Pb-Pb, run 568663): without downsampling (left) and with the full-pass caps (right; far K0s black, far Λ magenta).
V0 pT per class: without downsampling (black), with the full-pass caps (filled, flat in log pT), and weighted (open, reproduces the spectrum).
🤖 Generated with Claude Code